<template>
  <div class="full-page">
    <!-- 缓存当前router-view装载的Home/Msg/Mine组件 -->
    <router-view></router-view>
    <tab-bar></tab-bar>
  </div>
</template>

<script>
import TabBar from "../components/tab-bar.vue";
import { mapState } from "vuex";
export default {
  name: "root",
  components: {
    [TabBar.name]: TabBar,
  },
  computed: {
    ...mapState("user", ["isLogin"]),
  },
  watch: {
    //
    isLogin(newValue) {
      if (!newValue) {
        this.$router.replace("/login");
      }
    },
  },
  created() {
    // 登录状态为true，还需要验证。
    if (this.isLogin) {
      this.$store.dispatch("user/checkLoginAction");
    }
  },
};
</script>

<style></style>
